<?php
	/**
	 * 获取Rank列表
	 */
    class RankCharts extends APIBase {
		
		public $tag = "RankCharts";
		public $isLogin = false;
		public function before() {
			$this->initCacheRedis();
			return true;
		}

		public function logic() {
			$data = array();
			//1号场馆金币排行
// 			$keys1 = $this->cache_redis->lRange("am1:ids", 0, -1);
			$res = $this->cache_redis->keys('am*');
			if(!$res){
				$this->returnError(301,'there is no current rankcharts now!');
			}else{
			$amountCharts1 = array();
			for ($i=0;$i<15;$i++){
				$charts = $this->cache_redis->hGetall("am3:r{$i}");
				$ncharts["uid"] = (int)$charts["uid"];
				$ncharts["name"] = $charts["name"];
				$ncharts["num"] = (int)$charts["num"];
				$ncharts["amount"] = (int)$charts["amount"];
				$amountCharts1[] = $ncharts;
			}
// 			var_dump($amountCharts1);exit;
			$data['amountCharts1'] = $amountCharts1;
			$data['desa1'] = array('desc'=>Game::$desc1);
			unset($charts);
			
			
			//1号场馆胜局排行
// 			$keys2 = $this->cache_redis->lRange("bc1:ids", 0, -1);
			$boardCharts1 = array();
			for ($i=0;$i<15;$i++){
				$charts = $this->cache_redis->hGetall("bc3:r{$i}");
				$ncharts["uid"] = (int)$charts["uid"];
				$ncharts["name"] = $charts["name"];
				$ncharts["num"] = (int)$charts["num"];
				$ncharts["win_counts"] = (int)$charts["win_counts"];
				$boardCharts1[] = $ncharts;
			}
			$data['boardCharts1'] = $boardCharts1; 
			$data['desb1'] = array('desc'=>Game::$desc2);
			unset($charts);
			
			
			//2号场馆金币排行
// 			$keys3 = $this->cache_redis->lRange("am2:ids", 0, -1);
			$amountCharts3 = array();
			for ($i=0;$i<15;$i++){
				$charts = $this->cache_redis->hGetall("am4:r{$i}");
				$ncharts["uid"] = (int)$charts["uid"];
				$ncharts["name"] = $charts["name"];
				$ncharts["num"] = (int)$charts["num"];
				$ncharts["amount"] = (int)$charts["amount"];
				$amountCharts3[] = $ncharts;
			}
			$data['amountCharts3'] = $amountCharts3;
			$data['desa3'] = array('desc'=>Game::$desc1);
			unset($charts);
			
			
			//2号场馆胜局排行
// 			$keys4 = $this->cache_redis->lRange("bc2:ids", 0, -1);
			$boardCharts3 = array();
			for ($i=0;$i<15;$i++){
				$charts = $this->cache_redis->hGetall("bc4:r{$i}");
				$ncharts["uid"] = (int)$charts["uid"];
				$ncharts["name"] = $charts["name"];
				$ncharts["num"] = (int)$charts["num"];
				$ncharts["win_counts"] = (int)$charts["win_counts"];
				$boardCharts3[] = $ncharts;
			}
			//var_dump($boardCharts3);exit;
			$data['boardCharts3'] = $boardCharts3;
			$data['desb3'] = array('desc'=>Game::$desc2);
			unset($charts);
			$this->returnData($data);
			}
		}
		
    	public function after() {
			$this->deinitCacheRedis();
		}
    }
?>